package com.controller;

import com.constant.Constant;
import com.entity.Praise;
import com.entity.User;
import com.service.PraiseService;
import com.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * date:2021/5/7
 * description:
 * Author:Stargazer
 */
@Controller
@RequestMapping("/praise")
public class PraiseController {
    @Autowired
    PraiseService praiseService;

    /**
     * 点赞业务
     *
     * @param commentId
     * @param session
     * @return
     */
    @RequestMapping("/tgPraise.do")
    @ResponseBody
    public AjaxResult selPraise(@RequestParam("comment_id") Integer commentId, HttpSession session) {
        User user = (User) session.getAttribute(Constant.SESSION_USER);
        Integer uid = user.getId();
        AjaxResult ajaxResult = praiseService.doPraise(uid, commentId);
        return ajaxResult;
    }
}
